package chapter5.No5_1_定时器Timer的使用.demo1;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

/**
 * Timer和TimerTask结合使用
 * Timer的schedule()方法的作用是：在指定的日期执行一次某任务
 * Created by Administrator on 2016/11/24.
 */
public class Main {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.SECOND, 10);
        Date date = c.getTime();

        MyTask task = new MyTask();
        Timer timer = new Timer();
        timer.schedule(task, date);
        System.out.println("开始运行的时间："+System.currentTimeMillis());
    }
}
